﻿using System;
using Framework;

namespace TemplateEngine.TranslateFunctions
{
    internal class ParamFunction : ICommand
    {
        public string Execute(System.Xml.XmlNode xmlNode, TemplateNode templateNode, object[] args)
        {
            if(args.Length ==0 )
            {
                throw new TemplateEngineException("param函数，必须带一个参数");
            }
            string paramName = args[0].ToString();

            if (string.IsNullOrWhiteSpace(paramName))
            {
                throw new TemplateEngineException("param函数参数不能为空");
            }

            return templateNode.Document.Param[paramName] ?? string.Empty;
        }
    }
}
